using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using RMSM;

namespace AC.Report
{
	public partial class DichVu : DevExpress.XtraReports.UI.XtraReport
	{
		private LanDichVuKhacBOCollection lanDichVuKhacBOCollection = null;

		public DichVu(string title, int HopDongID, CTDichVuKhacBOCollection chiTietDichVuKhacBOCollection, LanDichVuKhacBOCollection lanDichVuKhacBOCollection)
		{
			InitializeComponent();

			if (title == null)
				this.ReportHeader.Visible = false;
			else
				this.lblTitle.Text = title;

			if (lanDichVuKhacBOCollection == null)
				this.lanDichVuKhacBOCollection = LanDichVuKhacBOCollection.GetLanDichVuKhacBOCollection("HOPDONGID=" + HopDongID, "LANDICHVUKHACID");
			else
				this.lanDichVuKhacBOCollection = lanDichVuKhacBOCollection;

			this.lblGhiChu.SummaryGetResult += new SummaryGetResultHandler(lblGhiChu_SummaryGetResult);
			this.lblNgayGiao.SummaryGetResult += new SummaryGetResultHandler(lblNgayGiao_SummaryGetResult);


			this.bds.DataSource = chiTietDichVuKhacBOCollection;
		}

		private void lblGhiChu_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanDichVuKhacID = (int)GetCurrentColumnValue("LanDichVuKhacID");
			LanDichVuKhacBO lanDichVuKhacBO = this.lanDichVuKhacBOCollection.GetBO(LanDichVuKhacID);
			e.Result = (string.IsNullOrEmpty(lanDichVuKhacBO.GhiChu) ? "" : lanDichVuKhacBO.GhiChu);
			e.Handled = true;
		}

		private void lblNgayGiao_SummaryGetResult(object sender, SummaryGetResultEventArgs e)
		{
			int LanDichVuKhacID = (int)GetCurrentColumnValue("LanDichVuKhacID");
			LanDichVuKhacBO lanDichVuKhacBO = this.lanDichVuKhacBOCollection.GetBO(LanDichVuKhacID);
			if (lanDichVuKhacBO.NgayGiao == null)
				e.Result = "";
			else
				e.Result = lanDichVuKhacBO.NgayGiao.Value.ToString("dd/MM/yyyy  HH:mm");
			e.Handled = true;
		}
	}
}
